/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package connection;

import entities.UserAccount;
import java.sql.CallableStatement;
import java.sql.Connection;

/**
 *
 * @author Admin
 */
public class UserDB {
    private String url;
    private String user;
    private String password;

    public UserDB(String url, String user, String password) {
        this.url = url;
        this.user = user;
        this.password = password;
    }
    
    public boolean createAccount(UserAccount uac){
        try {
            Connection conn = ConnectionUtil.getConnection(url, user, password);
            CallableStatement cstmt = conn.prepareCall("{call createAccount(?, ?, ?, ?, ?, ?, ?)}");
            cstmt.setString(1, uac.getUsername());
            cstmt.setString(2, uac.getPassword());
            cstmt.setString(3, uac.getFullname());
            cstmt.setString(4, uac.getDateofbirth());
            cstmt.setString(5, uac.getEmail());
            cstmt.setString(6, uac.getPhonenuber());
            cstmt.setString(7, uac.getImage());
            int rows = cstmt.executeUpdate();
            conn.close();
            return rows > 0;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}
